"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
  data() {
    return {
      recordList: []
      // 存储学习记录的数组
    };
  },
  methods: {
    // 获取学习记录
    async fetchStudyRecords() {
      try {
        const token = await this.getTokenFromFile();
        const url = "http://106.15.182.86:9099/studyrecord";
        const header = {
          "Authorization": token,
          "Content-Type": "application/json"
        };
        const data = {
          page: 1,
          size: 10
        };
        const [error, response] = await common_vendor.index.request({
          url,
          method: "POST",
          header,
          data
        });
        if (error) {
          console.error("请求失败:", error);
          return;
        }
        if (response.code === 200) {
          this.recordList = response.data;
          console.log("学习记录:", this.recordList);
        } else {
          console.error("请求失败:", response.data.message);
        }
      } catch (error) {
        console.error("请求异常:", error);
      }
    },
    // 从本地文件读取token
    getTokenFromFile() {
      return new Promise((resolve, reject) => {
        common_vendor.index.getStorage({
          key: "token",
          success: function(res) {
            resolve(res.data);
            console.log("token:", res.data);
          },
          fail: function(err) {
            reject(err);
          }
        });
      });
    },
    // 返回上一页
    goBack() {
      common_vendor.index.navigateBack();
    },
    // 加载更多数据
    loadMore() {
    }
  },
  onShow() {
    this.fetchStudyRecords();
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
    b: common_vendor.f($data.recordList, (item, index, i0) => {
      return {
        a: common_vendor.t(item.CREATE_at),
        b: common_vendor.t(item.OK_sum),
        c: index
      };
    }),
    c: common_vendor.o((...args) => $options.loadMore && $options.loadMore(...args))
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-cef81a41"]]);
wx.createPage(MiniProgramPage);
